package com.haixiaoke.business;

import com.haixiaoke.smartLock.haixiaoke.SmartLockHxkCallBackService;
import com.haixiaoke.smartLock.huixiangjia.SmartLockHxjCallBackService;
import com.haixiaoke.smartLock.tianwanghulian.SmartLockTwhlCallBackService;
import com.haixiaoke.smartLock.yaluete.SmartLockYLTCallBackService;
import com.haixiaoke.smartLock.youdian.SmartLockYdCallBackService;
import com.haixiaoke.vo.HuiXiangJiaCallBack;
import com.haixiaoke.vo.ydCallBackVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * 智能锁回调Controller
 *
 * @author qixi
 * @date 2023-05-27
 */
@RestController
@RequestMapping("/callback")
public class SmartLockCallBackController {

    @Autowired
    private SmartLockTwhlCallBackService smartLockTwhlCallBackService;
    @Autowired
    private SmartLockYLTCallBackService smartLockYLTCallBackService;
    @Autowired
    private SmartLockYdCallBackService smartLockYdCallBackService;
    @Autowired
    private SmartLockHxkCallBackService smartLockHxkCallBackService;
    @Autowired
    private SmartLockHxjCallBackService smartLockHxjCallBackService;

    /**
     * 天网互联-日志回调
     *
     * @param map
     * @return
     */
    @PostMapping("/twhl/log")
    @ResponseBody
    public String twhlLockCallback(@RequestBody Map<String, Object> map) {
        return smartLockTwhlCallBackService.lockCallback(map);
    }

    /**
     * 亚略特-日志回调
     *
     * @param map
     * @return
     */
    @PostMapping("/ylt/log")
    @ResponseBody
    public Map<String, Object> yltLockCallback(@RequestBody Map<String, Object> map) {
        return smartLockYLTCallBackService.lockCallback(map);
    }

    /**
     * 优电-日志回调
     *
     * @param vo
     * @return
     */
    @PostMapping("/yd/log")
    @ResponseBody
    public Map<String, Object> ydLockCallback(@RequestBody ydCallBackVo vo) {
        return smartLockYdCallBackService.lockCallback(vo);
    }

    /**
     * 嗨小克-日志回调-设备上线回调
     */
    @PostMapping("/devices")
    @ResponseBody
    public Map<String, Object> hxkLockCallback(@RequestBody Map<String, Object> map) {
        smartLockHxkCallBackService.devices(map);
        Map<String, Object> response = new HashMap<>();
        response.put("code",0);
        response.put("msg","操作成功");
        return response;
    }

    /**
     * 嗨小克-日志回调-设备开门回调
     */
    @PostMapping("/deviceOpenRecords")
    @ResponseBody
    public Map<String, Object> hxkOpenCallBack(@RequestBody Map<String, Object> map){
        return smartLockHxkCallBackService.deviceOpenRecords(map);
    }

    /**
     * 嗨小克-日志回调-抓拍记录上报
     */
    @PostMapping("/devicePhotos")
    @ResponseBody
    public Map<String, Object> deviceTakePhotos(@RequestBody Map<String, Object> map){
        return smartLockHxkCallBackService.deviceTakePhotos(map);
    }


    /**
     * 慧享佳锁日志回调
     * @param huiXiangJiaCallBack 回调数据
     * @return
     */
    @PostMapping("/hxj/log")
    @ResponseBody
    public Map<String, Object> hxjCallBack(@RequestBody HuiXiangJiaCallBack huiXiangJiaCallBack){
        return smartLockHxjCallBackService.callBack(huiXiangJiaCallBack);
    }
}
